﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using ProgNetComponents.Design.TypeConverters;
using ProgNetComponents.Classes;

namespace ProgNetComponentsDx.Validation.Design
{
    public class ValidationRuleForTableTypeConverter : CollectionItemTypeConverterAdv<ValidationRuleForTable>
    {

        protected override ProgNetComponents.Classes.TypedObjectCollection GetConstructorParamters(ValidationRuleForTable item)
        {
            TypedObjectCollection parameters = new TypedObjectCollection();
            
            if (item.Table != null)
            {
                parameters.Add(item.Table);
                if (item.Filter.IsNotNull())
                    parameters.Add(item.Filter);
                if (item.Rules.Count > 0)
                    parameters.Add(item.Rules.ToArray());
            }
            return parameters;
        }
    }
}
